/**
 * Copyright @ 2000 ysten Co. Ltd. 
 * All right reserved.     
 * @author: wangmin
 * date: 2016-07-11     
 */
package com.task.repository;

import com.task.entity.ChildTask;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface IChildTaskRepository extends JpaRepository<ChildTask, Long>, JpaSpecificationExecutor<ChildTask> {
     
    @Query(value = "select max(code) from tufa_child_task where code like %?1% limit 1",nativeQuery = true)
    String findMaxCodeByCode(String code);

    @Query("select count(*) from ChildTask where parentTaskId=?1")
    Integer getCountByParentTaskId(Long parentTaskId);

    @Modifying
    @Query("delete from ChildTask where parentTaskId=?1")
	void deleteByParentTaskId(Long id);
}
